//: reusing/Orc.java
// The protected keyword.
package chapter7;
import static utility.Print.*;

import java.util.ArrayList;

import simple.*;

/**
 * Exercise 15: (2) Create a class inside a package. Your class should contain a
 * protected method. Outside of the package, try to call the protected method
 * and explain the results. Now inherit from your class and call the protected
 * method from inside a method of your derived class.
 * 
 * @author rDiaconescu
 * 
 */

class ExtendedPerson extends Person {
	private ArrayList<String> friends = new ArrayList<String>();

	public ExtendedPerson(String name, int age) {
	    super(name, age);
	    // TODO Auto-generated constructor stub
    }
	
	public void addFriend(String name) {
		friends.add(name);
	}

	@Override
    public String toString() {
	    return "Person [" + super.toString() + "]" + "\nExtendedPerson [friends=" + friends + "]";
    }
	
	public void GrowOldAndGetMaried() {
		this.growOld();
		this.getMarried("Married");
	}
	
	
}

public class Exercise15 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ExtendedPerson p = new ExtendedPerson("Radu", 29);
		
		p.addFriend("Mike");
		p.addFriend("Claudia");
		p.addFriend("Andrei");
				
		print(p);
		p.GrowOldAndGetMaried();
		print(p);
		
		//protected is not allowed outside the same package
		//p.growOld();
		
	}
}